package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: RequestDemo03
 * @Description:
 * @author: RZS
 * @date: 2022/4/11  15:00
 */
@WebServlet("/rd3.do")
public class RequestDemo03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 修改request缓冲区的字符集为UTF-8，放在请求数据中文乱码
        req.setCharacterEncoding("utf-8");

        // 获取表单提交数据
        // 获取用户名，注：该方法的参数值为表单中对应标签的name属性值
        String username = req.getParameter("uname");
        // 获取用户密码
        String pwd = req.getParameter("pwd");
        // 获取下拉选的值
        String sel = req.getParameter("sel");
        // 获取多选框的值
        String[] hobbies = req.getParameterValues("hobby");
        String[] educations = req.getParameterValues("education");

        System.out.println(username);
        System.out.println(pwd);
        System.out.println(sel);
        System.out.println(Arrays.toString(hobbies));
        System.out.println(Arrays.toString(educations));

    }
}
